<?php

namespace App\Http\Controllers\api;

use App\Http\Controllers\Controller;
use App\Models\GoodsType;
use App\Models\StoreGoods;
use App\Service\CommonService;


use Illuminate\Http\Request;
//商品分类控制器 （何家令11.11）
class GoodsTypeController extends Controller
{
    //商品分类数据查询
    public function selectGoodsType()
    {
        $obj=new GoodsType();
        $result=$obj->selectData();
        $data=$result->toArray();
        $resData=CommonService::infiniteSort($data);
        return response()->json(['code'=>200,'mes'=>'商品分类查询成功','data'=>$resData]);
    }
    //查询分类商品
    public function selectTypeGoods(Request $request)
    {
        $typeid=intval($request->get('id'));
        if(empty($typeid)) return CommonService::fail(9999,'条件不能为空',null);
        $data=StoreGoods::where('cate_id',$typeid)->get();
       if($data) return CommonService::success(200,'分类商品查询成功',$data);



    }
}
